package com.itheima.annotation;

import org.junit.jupiter.api.Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class TestAnnotation {
    @Test
    public void test() throws NoSuchMethodException {
        Class c = Demo.class;
        if(c.isAnnotationPresent(MyTest1.class)){
            MyTest1 ann = (MyTest1) c.getDeclaredAnnotation(MyTest1.class);
            System.out.println(ann.value());
        }

        Method m = c.getDeclaredMethod("test1");
        if(m.isAnnotationPresent(MyTest1.class)){
            MyTest1 ann = (MyTest1) m.getDeclaredAnnotation(MyTest1.class);
            System.out.println(ann.value());
        }
    }
}
